<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul{
            width: 800px;
            margin: auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            text-align: center;

        }
        li{
            width: 33%;
            height: 200px;
            list-style: none;
            /* background-color: red; */
          
        }
        li img{
    
            height: 160px;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for='item in cates' :key='item.id'>
                <h2>{{ item.name}}</h2>
                <img :src="item.icon" alt="">
            </li>
        </ul>
    </div>


    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.13/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                cates: []
            },
            created() {
                this.fethCates()
            //在这里调用methods中方法
            },
            methods: {
                //在methods 中定义方法
                fethCates() {
                    axios.get('https://api.it120.cc/conner/shop/goods/category/all',{
                        params:{
                            a:1,
                            b:2
                        }
                    }
                    ).then(res => {
                        if(res.data.code===0){
                            console.log(res.data.data)
                            this.cates = res.data.data
           
                        }
                        
                    })
                }
            }

        })
    </script>

</body>

</html>